package cn.wolfcode.transfer.service.impl;

import cn.wolfcode.transfer.domain.Department;
import cn.wolfcode.transfer.mapper.DepartmentMapper;
import cn.wolfcode.transfer.qo.QueryObject;
import cn.wolfcode.transfer.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Override
    public int insert(Department record) {
        int insert = departmentMapper.insert(record);
        return insert;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        int i = departmentMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public int updateByPrimaryKey(Department record)
    {
        int i = departmentMapper.updateByPrimaryKey(record);
        return i;
    }

    @Override
    public Department selectByPrimaryKey(Long id) {
        Department department = departmentMapper.selectByPrimaryKey(id);
        return department;
    }

    @Override
    public List<Department> selectAll() {
        List<Department> departments = departmentMapper.selectAll();
        return departments;
    }

    @Override
    public PageInfo<Department> getPageInfo(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Department> departments = departmentMapper.totalList(qo);
        return new PageInfo<Department>(departments);
    }
}
